package com.ruoyi.develop.factory.factoryProductStore.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.develop.factory.factoryProductProcess.domain.FactoryProductProcess;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryProductStore.domain.FactoryProductStore;
import com.ruoyi.develop.factory.factoryProductStore.service.IFactoryProductStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 成品入库数据采集Controller
 * @author qh
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/factoryProductStore/factoryProductStore")
public class FactoryProductStoreController extends BaseController {
    @Autowired
    private IFactoryProductStoreService factoryProductStoreService;

    /**
     * 查询成品入库数据采集列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryProductStore entity) {
        startPage();
        List<FactoryProductStore> list = factoryProductStoreService.selectList(entity);
        return getDataTable(list);
    }


    /**
     * 根据到货查询成品入库数据采集列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:query')")
    @GetMapping("/listByFahuoDetail")
    public TableDataInfo listByFahuoDetail(FactoryProductStore entity) {
        startPage();
        List<FactoryProductStore> list = factoryProductStoreService.selectListByFahuoDetail(entity);
        return getDataTable(list);
    }

    /**
     * 导出成品入库数据采集列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:export')")
    @Log(title = "成品入库数据采集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryProductStore entity) {
        List<FactoryProductStore> list = factoryProductStoreService.selectList(entity);
        ExcelUtil<FactoryProductStore> util = new ExcelUtil<FactoryProductStore>(FactoryProductStore. class);
        util.exportExcel(response, list, "成品入库数据采集数据");
    }

    /**
     * 获取成品入库数据采集详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryProductStoreService.selectById(id));
    }

    /**
     * 新增成品入库数据采集
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:add')")
    @Log(title = "成品入库数据采集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryProductStore entity) {
        return toAjax(factoryProductStoreService.insert(entity));
    }

    /**
     * 修改成品入库数据采集
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:edit')")
    @Log(title = "成品入库数据采集", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryProductStore entity) {
        return toAjax(factoryProductStoreService.update(entity));
    }

    /**
     * 删除成品入库数据采集
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:remove')")
    @Log(title = "成品入库数据采集", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryProductStoreService.deleteByIds(ids));
    }
}
